#ifndef AUTOFOCUSINTERFACE_H
#define AUTOFOCUSINTERFACE_H

#include <QObject>

#include "AutoFocus/FocusMeasureObject.h"
#include "Camera/CameraCommon/CameraImage.h"
//#include "Camera/CameraCommon/IndustryCamera.h"
#include "StageControl.h"


namespace Qly
{

class AutoFocusInterface : public QObject
{
    Q_OBJECT
public:
    explicit AutoFocusInterface(QObject *parent = nullptr);
    void attach(FocusMeasureObject *focus, StageControl *control, Qly::IndustryCamera * camera);
    void setRange(double lower_mm, double higher_mm, double speed_mmps); // 设置相对于当前位置的相对位移。
signals:

    /**
     * @brief autoFocusFinished 自动对焦完成时发出这个信号
     * @param ok  true 表示自动对焦成功， false 表示失败。
     */
    void autoFocusFinished(bool ok); // true 表示对焦成功，

public slots:
    virtual void startAutoFocus() = 0; //启动自动对焦，这个是核心功能，必须实现
    virtual void stop() = 0; // 停止自动对焦，这个是核心功能，必须实现

protected slots:
    virtual void zMoveFinished(int32_t stopcode) = 0;
    virtual void newFocusValue(QImage& image, double score) = 0;
protected:
    Qly::FocusMeasureObject * m_pFocusObject = nullptr;
    StageControl *m_pStageControl = nullptr;
    Qly::IndustryCamera * m_pCamera = nullptr;

    double m_low_mm = 0.0;
    double m_high_mm = 0.0;
    double m_z_mm = 0.0;
    double m_speed_mmps = 1.0;
};

}


#endif // AUTOFOCUSINTERFACE_H
